package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.wap.model.dto.QuickPayDto;
import com.cssw.fyzb.wap.model.dto.QuickPaySmsOkDto;
import com.cssw.fyzb.wap.model.dto.QuickSignDto;
import com.cssw.fyzb.wap.model.dto.QuickSignSmsOkDto;
import com.cssw.fyzb.wap.model.vo.*;
import com.cssw.fyzb.wap.service.QuickPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author
 */
@Api(description = "快捷支付相关接口")
@RestController
@RequestMapping("/quickPay")
public class QuickPayController {

    @Autowired
    private QuickPayService quickPayService;

    @ApiOperation(value = "查询快捷签约信息")
    @RequestMapping(value = "/getQuickSign", method = RequestMethod.GET)
    @ResponseBody
    public AjaxData<UserQuickSignVo> getQuickSign() {
        return quickPayService.getQuickSign(UserContext.getUserId());
    }

    @ApiOperation(value = "快捷签约发送验证码")
    @ApiImplicitParam(name = "dto", value = "快捷签约发送验证码", dataType = "QuickSignDto")
    @RequestMapping(value = "/quickSign", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<QuickSignResultVo> quickSign(@RequestBody QuickSignDto dto) {
        return quickPayService.quickSign(UserContext.getUserId(), dto.getBankCode(),
                dto.getBankName(), dto.getCardNo(), dto.getMobile(), dto.getUserName(), dto.getIdCard());
    }

    @ApiOperation(value = "快捷签约短信校验")
    @ApiImplicitParam(name = "dto", value = "快捷签约短信校验", dataType = "QuickSignSmsOkDto")
    @RequestMapping(value = "/quickSignSmsOk", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<QuickSignSmsResultVo> quickSignSmsOk(@RequestBody QuickSignSmsOkDto dto) {
        return quickPayService.quickSignSmsOk(UserContext.getUserId(),dto.getOrderNo(), dto.getVerifyCode());
    }


    @ApiOperation(value = "查询快捷签约信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderNo", value = "订单编号", paramType = "query", dataType = "string", required = true)
    })
    @GetMapping("queryQuickSignOrder")
    @ResponseBody
    public AjaxData queryQuickSignOrder(String orderNo) throws Exception {
        return quickPayService.queryQuickSignOrder(UserContext.getUserId(), orderNo);
    }

    @ApiOperation(value = "快捷支付发送验证码")
    @ApiImplicitParam(name = "dto", value = "快捷支付发送验证码", dataType = "QuickPayDto")
    @RequestMapping(value = "/quickPay", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<QuickPayResultVo> quickPay(@RequestBody QuickPayDto dto) {
        return quickPayService.quickPay(UserContext.getUserId(), dto.getQuickId(), dto.getBusiType(), dto.getExtendData());
    }


    @ApiOperation(value = "快捷支付短信校验")
    @ApiImplicitParam(name = "dto", value = "快捷支付短信校验", dataType = "QuickPaySmsOkDto")
    @RequestMapping(value = "/quickPaySmsOk", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<QuickPaySmsResultVo> quickPaySmsOk(@RequestBody QuickPaySmsOkDto dto) {
        return quickPayService.quickPaySmsOk(UserContext.getUserId(), dto.getOrderNo(), dto.getVerifyCode());
    }

    @ApiOperation(value = "查询快捷支付信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderNo", value = "订单编号", paramType = "query", dataType = "string", required = true)
    })
    @GetMapping("queryQuickPayOrder")
    @ResponseBody
    public AjaxData queryQuickPayOrder(String orderNo) throws Exception {
        return quickPayService.queryQuickPayOrder(UserContext.getUserId(), orderNo);
    }
}
